
import Web from './web'
import Ios from './ios'
import Android from './android'
import Other from './other'
export function getAgent() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        console.log('微信')
        return 'web'
    } else if (ua.indexOf("android") != -1) {
        // 这是Android设备
        return 'android'
    } else if (!!ua.match(/\(i[^;]+;( U;)? cpu.+mac os x/)) {
        // 这是iOS设备
        return 'ios'
    } else {
        // 未知设备类型
        return 'else'
    }
}
if (import.meta.env.MODE === "development") {
    console.log('到这了')
  localStorage.setItem("isWeb", "true");
}
export default (function initBridge(deviceType) {
    if (localStorage.getItem('isWeb')) deviceType = 'ELSE'
    console.log(deviceType)
    switch (deviceType) {
        case 'WEB':
            const web = new Web()
            web.defineFunc()
            break;
        case 'ANDROID':
            const android = new Android()
            android.defineFunc()
            break;
        case 'IOS':
            const ios = new Ios()
            ios.defineFunc()
            break;
        case 'ELSE':
            const other = new Other()
            other.defineFunc()
            break;
    }
    TongBridge.deviceType = deviceType
})(getAgent().toUpperCase())
